<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function pinyin($string, $slug = "") {
    return str_replace(" ", $slug, transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $string));
}

function getHttpStatus() {
    $objClass = new \ReflectionClass(\Symfony\Component\HttpFoundation\Response::class);
    return array_values($objClass->getConstants());
}
if (!function_exists('randomFloat')) {
    function randomFloat($min = 0, $max = 1) {
        return $min + mt_rand() / mt_getrandmax() * ($max - $min);
    }
}
if (!function_exists('addActivityLog')) {
    function addActivityLog($desc, $model=null, $logName="default", $atts=[]) {
        $logs = activity($logName);
        if($model) {
          $logs->performedOn($model);  
        }
        $logs->causedBy(auth()->user());  
        if($atts) {
          $logs->withProperties($atts);  
        }
        $logs->log($desc);
    }
}

if (!function_exists('addAction')) {
    function addAction($table = 't_prideviceinfo') {
        $save = [
            'updatetime' => date('Y-m-d H:i:s')
        ];
        \App\Models\Changetable::where('table', $table)->update($save);
    }
}